package com.gimi.cloud.bbp.dao.dao.task;

import com.gimi.cloud.bbp.dao.dao.sys.BaseDao;
import com.gimi.cloud.bbp.dao.myMapper.MyMapper;
import com.gimi.cloud.bbp.dto.task.ScheduleJobDTO;
import com.gimi.cloud.bbp.entity.task.ScheduleJobEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 定时任务相关数据库访问层
 * @author wbj
 * @version 1.0
 * @Description
 * @create 2018-02-06
 **/
@Mapper
public interface ScheduleJobDao extends MyMapper<ScheduleJobEntity>,BaseDao<ScheduleJobEntity,ScheduleJobDTO> {

    /**
     * 根据JobId获取定时任务信息
     * @param jobId 定时任务id
     * @return 查询结果
     * @throws Exception
     */
    @Select("SELECT job.*,det.job_name" +
            " FROM schedule_job job" +
            " LEFT JOIN qrtz_job_details det ON det.JOB_NAME = CONCAT('GIMIII_BBP_TASK_',job.job_id)" +
            " WHERE job.is_delete = 0 AND job_id = #{jobId}")
    ScheduleJobDTO queryScheduleJobByJobId(@Param("jobId") Integer jobId) throws  Exception;
}
